<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script src="./lib/jquery.js"></script>
    <script>
        $(function() {
            var arr = [10, 33, 44, 2, 6, 7, 95, 234, 23, 5];
            // var ret = arr.filter(function(item) {
            //         if (item > 10) {
            //             return item;

            //         }
            //     })
            // console.log(ret);
            Array.prototype.myFilter = function(callback) {
                var ret = [];
                // for (var i = 0; i < this.length; i++) {

                //     var flag = callback(this[i]);
                //     if (flag) {
                //         ret.push(this[i]);
                //     }
                // }
                this.forEach(function(ele) {
                    var flag = callback(ele);
                    if (flag) {
                        ret.push(ele);
                    }
                })
                return ret;
            }

            var ret = arr.myFilter(function(item) {
                if (item > 10) {
                    return item;
                }
            })
            console.log(ret);
        })
    </script>
</body>

</html>